export default {
  getBase64 (img, width, height) {
    const canvas = document.createElement('canvas')
    canvas.width = width
    canvas.height = height
    canvas.getContext('2d').drawImage(img, 0, 0, width, height)
    const ext = img.src.substring(img.src.lastIndexOf('.') + 1).toLowerCase()
    return canvas.toDataURL('image/' + ext)
  }
}
